//
// Created by liuping on 2018/10/14.
//

#include "src/circle_queue.h"
#include <iostream>

using std::cout;
using std::endl;
template <typename T>
void assert(T a, T b, int line) {
    cout << "line:" << line;
    if (a != b) {
        std::cout << "a != b " << a << " " << b << std::endl;
    } else {
        cout <<"pass" <<endl;
    }
}

#define Assert(a, b) assert(a, b, __LINE__);

void test_circle_queue() {
    CircleQueue<int, 2> cc1_queue;
    cc1_queue.push(1);
    cc1_queue.push(2);
    cc1_queue.push(3);
    Assert(cc1_queue.pop(), 2);

    CircleQueue<int, 4> cc_queue;
    cc_queue.push(1);
    Assert(cc_queue.size(), 1);
    cc_queue.push(2);
    Assert(cc_queue.size(), 2);
    cc_queue.push(3);
    Assert(cc_queue.size(), 3);

    cc_queue.push(4);
    cc_queue.push(5);
    cc_queue.push(400);
    for (auto iter = cc_queue.begin(); iter != cc_queue.end(); ++iter) {
        cout << "... " << *iter<< endl;
    }

    for (auto item : cc_queue) {
        cout <<"+++ "<< item <<endl;
    }
}

int main() {
    test_circle_queue();
}